<?php

use Biz\model\activity\ActivityAwardDelivery;
use Biz\model\activity\ActivityBasicInterface;
use Doraemon\model\Phone;

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';



//$model = \Biz\model\activity\ActivityAwardDelivery::class;
//$scene = \hhz\constant\basic\UserExtendPhoneScene::ACTIVITY_CREATE_WIKI_LIST;

$model = \Biz\model\SamsungActivity\SamsungJoinUserListModel::class;
$scene = \hhz\constant\basic\UserExtendPhoneScene::ACTIVITY_SAMSUNG_JOIN_USER;

$model = \Biz\model\IkeaActivity\IkeaActivityWinnerListModel::class;
$scene = \hhz\constant\basic\UserExtendPhoneScene::ACTIVITY_IKEA_WINNER;

$model = \Biz\model\MijiaSmartKitchen\MijiaSmartKitchenWinningRecord::class;
$scene = \hhz\constant\basic\UserExtendPhoneScene::ACTIVITY_MIJIA_SMART_KITCHEN;

$model = \Biz\model\activity\NarwalDesigner::class;
$scene = \hhz\constant\basic\UserExtendPhoneScene::ACTIVITY_NARWAL_DESIGNER_COLLECT;

$model = \Biz\model\springHomeDecActivity\MSpringHomeDecWinningRecord::class;
$scene = \hhz\constant\basic\UserExtendPhoneScene::ACTIVITY_SPRING_HOME;

$model = \Biz\model\activity\CplRecord::class;
$scene = \hhz\constant\basic\UserExtendPhoneScene::ACTIVITY_CPL_RECORD;
$field = 'phone';
$field = 'tel';
$model = \Biz\model\brandActivity\UserAddressModel::class;
$scene = \hhz\constant\basic\UserExtendPhoneScene::NEW_PRODUCT_USER_ADDRESS_PHONE;

$list = $model::select("*");
foreach ($list as $v) {
    if (!isset($v[$field])) {
        echo "field phone not found";
        break;
    }
    $phone = $v[$field];
    $encrypt = "";
    $decrypt = "";
    if (strlen($phone)) {
        $encrypt = Phone::addExtendPhone($phone,$scene);
        if ($encrypt) {
            $decrypt = Phone::getExtendPhone($encrypt, $scene);
            $model::update([$field => $encrypt], ['id' => $v['id']]);
        }
    }
    $row = [$v['id'], $phone, $encrypt, $decrypt];
    echo implode("\t", $row), PHP_EOL;
}

